package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.pojo.Contact;
import com.gxa.pojo.Customer;
import com.gxa.service.ContactService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Api(value = "联系人test",tags = "联系人接口API")
public class ContactController {
    @Autowired
    private ContactService contactService;
    @RequestMapping(value = "/addContact",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "新增联系人",notes = "联系人表单数据",httpMethod = "post", response = R.class)
    public R addContact(@RequestBody Contact contact){
        return contactService.addContact(contact);
    }
    @RequestMapping(value = "/queryContact",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查找联系人",notes = "根据客户ID 查询对应联系人",httpMethod = "post", response = R.class)
    public R queryContact(@RequestBody Contact contact){
        System.out.println(contact);
        return contactService.queryContact(contact.getCustomer_id());
    }
    @RequestMapping(value = "/delContact",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除联系人",notes = "根据联系人ID 删除对应联系人",httpMethod = "post", response = R.class)
    public R delContact(@RequestBody Contact contact){
        return contactService.delContact(contact.getContact_id());
    }
    @RequestMapping(value = "/upDataContact",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "修改联系人",notes = "修改对应联系人信息",httpMethod = "post", response = R.class)
    public R upDataContact(@RequestBody Contact contact){
        return contactService.upDataContact(contact);
    }
    @RequestMapping(value = "/delCustomerContact",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除联系人",notes = "根据客户ID 删除对应联系人",httpMethod = "post", response = R.class)
    public R delCustomerContact(@RequestBody Customer customer){
        return contactService.delCustomerContact(customer.getCustomer_id());
    }

}
